﻿namespace HRM.CORE.Option
{
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using APP.HELPER;
    using Extra;
    using HRM.CORE.CLASS;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms; using Common;

    public class xucTimeKeeperOption : Common.xucBase
    {
        private SimpleButton btColorDefault;
        private ComboBoxEdit cboTimeKeeperTableDefault;
        private CheckEdit cheAutoAssignment;
        private CheckEdit cheAutoPetition;
        private CheckEdit cheShowAssignmentDialog;
        private CheckEdit cheShowPetitionDialog;
        private ColorEdit colorFriday;
        private ColorEdit colorHoliday;
        private ColorEdit colorMonday;
        private ColorEdit colorSaturday;
        private ColorEdit colorSunday;
        private ColorEdit colorThursday;
        private ColorEdit colorTuesday;
        private ColorEdit colorWednesday;
        private IContainer components = null;
        private FontDialog fontDialog1;
        private GroupBox groupBox1;
        private GroupBox groupBox2;
        private GroupBox groupBox3;
        private Label label1;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private LabelControl labelControl4;
        private LabelControl labelControl5;
        private LabelControl labelControl6;
        private LabelControl labelControl7;
        private LabelControl labelControl8;
        private XtraScrollableControl xtraScrollableControl1;
        private HRM.CORE.xucTimekeeperFormula xucTimekeeperFormula;

        public xucTimeKeeperOption()
        {
            this.InitializeComponent();
            this.LoadOption();
            this.LoadControlTimekeeperFormula();
        }

        private void btColorDefault_Click(object sender, EventArgs e)
        {
            this.colorMonday.EditValue = SystemColors.Info;
            this.colorTuesday.EditValue = Color.SeaShell;
            this.colorWednesday.EditValue = SystemColors.Info;
            this.colorThursday.EditValue = Color.SeaShell;
            this.colorFriday.EditValue = SystemColors.Info;
            this.colorSaturday.EditValue = Color.SeaShell;
            this.colorSunday.EditValue = Color.Azure;
            this.colorHoliday.EditValue = Color.FromArgb(0xc0, 0xff, 0xc0);
        }

        private void colorEdit1_EditValueChanged(object sender, EventArgs e)
        {
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.fontDialog1 = new FontDialog();
            this.groupBox1 = new GroupBox();
            this.cheShowPetitionDialog = new CheckEdit();
            this.cheShowAssignmentDialog = new CheckEdit();
            this.groupBox2 = new GroupBox();
            this.cheAutoPetition = new CheckEdit();
            this.cheAutoAssignment = new CheckEdit();
            this.xtraScrollableControl1 = new XtraScrollableControl();
            this.cboTimeKeeperTableDefault = new ComboBoxEdit();
            this.label1 = new Label();
            this.groupBox3 = new GroupBox();
            this.btColorDefault = new SimpleButton();
            this.labelControl8 = new LabelControl();
            this.colorHoliday = new ColorEdit();
            this.labelControl7 = new LabelControl();
            this.colorFriday = new ColorEdit();
            this.labelControl5 = new LabelControl();
            this.labelControl6 = new LabelControl();
            this.colorThursday = new ColorEdit();
            this.colorWednesday = new ColorEdit();
            this.labelControl4 = new LabelControl();
            this.labelControl3 = new LabelControl();
            this.labelControl2 = new LabelControl();
            this.colorSunday = new ColorEdit();
            this.colorSaturday = new ColorEdit();
            this.labelControl1 = new LabelControl();
            this.colorTuesday = new ColorEdit();
            this.colorMonday = new ColorEdit();
            this.groupBox1.SuspendLayout();
            this.cheShowPetitionDialog.Properties.BeginInit();
            this.cheShowAssignmentDialog.Properties.BeginInit();
            this.groupBox2.SuspendLayout();
            this.cheAutoPetition.Properties.BeginInit();
            this.cheAutoAssignment.Properties.BeginInit();
            this.xtraScrollableControl1.SuspendLayout();
            this.cboTimeKeeperTableDefault.Properties.BeginInit();
            this.groupBox3.SuspendLayout();
            this.colorHoliday.Properties.BeginInit();
            this.colorFriday.Properties.BeginInit();
            this.colorThursday.Properties.BeginInit();
            this.colorWednesday.Properties.BeginInit();
            this.colorSunday.Properties.BeginInit();
            this.colorSaturday.Properties.BeginInit();
            this.colorTuesday.Properties.BeginInit();
            this.colorMonday.Properties.BeginInit();
            base.SuspendLayout();
            this.groupBox1.Controls.Add(this.cheShowPetitionDialog);
            this.groupBox1.Controls.Add(this.cheShowAssignmentDialog);
            this.groupBox1.Location = new Point(0x10, 60);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(470, 0x5c);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Khi nhập k\x00fd hiệu chấm c\x00f4ng";
            this.cheShowPetitionDialog.Location = new Point(0x13, 0x3a);
            this.cheShowPetitionDialog.Name = "cheShowPetitionDialog";
            this.cheShowPetitionDialog.Properties.Caption = "Hiển thị hộp thoại nhập th\x00f4ng tin đơn xin nghỉ ph\x00e9p";
            this.cheShowPetitionDialog.Size = new Size(0x18d, 0x13);
            this.cheShowPetitionDialog.TabIndex = 1;
            this.cheShowAssignmentDialog.Location = new Point(0x13, 0x1c);
            this.cheShowAssignmentDialog.Name = "cheShowAssignmentDialog";
            this.cheShowAssignmentDialog.Properties.Caption = "Hiển thị hộp thoại nhập th\x00f4ng tin c\x00f4ng t\x00e1c";
            this.cheShowAssignmentDialog.Size = new Size(0x18d, 0x13);
            this.cheShowAssignmentDialog.TabIndex = 0;
            this.groupBox2.Controls.Add(this.cheAutoPetition);
            this.groupBox2.Controls.Add(this.cheAutoAssignment);
            this.groupBox2.Location = new Point(0x10, 0xa4);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new Size(0x1d8, 0x5c);
            this.groupBox2.TabIndex = 1;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Khi nhập qu\x00e1 tr\x00ecnh l\x00e0m việc của nh\x00e2n vi\x00ean";
            this.cheAutoPetition.Location = new Point(0x13, 0x39);
            this.cheAutoPetition.Name = "cheAutoPetition";
            this.cheAutoPetition.Properties.Caption = "Tự động cập nhật ng\x00e0y (ca) nghỉ ph\x00e9p v\x00e0o bảng chấm c\x00f4ng th\x00e1ng";
            this.cheAutoPetition.Size = new Size(0x18d, 0x13);
            this.cheAutoPetition.TabIndex = 1;
            this.cheAutoAssignment.Location = new Point(0x13, 0x1c);
            this.cheAutoAssignment.Name = "cheAutoAssignment";
            this.cheAutoAssignment.Properties.Caption = "Tự động cập nhật đi c\x00f4ng t\x00e1c v\x00e0o bảng chấm c\x00f4ng th\x00e1ng";
            this.cheAutoAssignment.Size = new Size(0x18d, 0x13);
            this.cheAutoAssignment.TabIndex = 0;
            this.xtraScrollableControl1.Controls.Add(this.cboTimeKeeperTableDefault);
            this.xtraScrollableControl1.Controls.Add(this.label1);
            this.xtraScrollableControl1.Controls.Add(this.groupBox3);
            this.xtraScrollableControl1.Controls.Add(this.groupBox2);
            this.xtraScrollableControl1.Controls.Add(this.groupBox1);
            this.xtraScrollableControl1.Dock = DockStyle.Fill;
            this.xtraScrollableControl1.Location = new Point(0, 0);
            this.xtraScrollableControl1.Name = "xtraScrollableControl1";
            this.xtraScrollableControl1.Size = new Size(0x204, 0x199);
            this.xtraScrollableControl1.TabIndex = 4;
            this.cboTimeKeeperTableDefault.EditValue = "Theo K\x00fd Hiệu (Dạng 1)";
            this.cboTimeKeeperTableDefault.Location = new Point(0x9e, 0x12);
            this.cboTimeKeeperTableDefault.Name = "cboTimeKeeperTableDefault";
            this.cboTimeKeeperTableDefault.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboTimeKeeperTableDefault.Properties.Items.AddRange(new object[] { "Theo K\x00fd Hiệu (Dạng 1)", "Theo K\x00fd Hiệu (Dạng 2)", "Theo Giờ C\x00f4ng", "Tăng Cường Giờ C\x00f4ng, L\x00e0m Việc Ri\x00eang" });
            this.cboTimeKeeperTableDefault.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
            this.cboTimeKeeperTableDefault.Size = new Size(0xf2, 20);
            this.cboTimeKeeperTableDefault.TabIndex = 6;
            this.label1.AutoSize = true;
            this.label1.Location = new Point(0x12, 0x15);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x86, 13);
            this.label1.TabIndex = 5;
            this.label1.Text = "Bảng chấm c\x00f4ng mặc định:";
            this.groupBox3.Controls.Add(this.btColorDefault);
            this.groupBox3.Controls.Add(this.labelControl8);
            this.groupBox3.Controls.Add(this.colorHoliday);
            this.groupBox3.Controls.Add(this.labelControl7);
            this.groupBox3.Controls.Add(this.colorFriday);
            this.groupBox3.Controls.Add(this.labelControl5);
            this.groupBox3.Controls.Add(this.labelControl6);
            this.groupBox3.Controls.Add(this.colorThursday);
            this.groupBox3.Controls.Add(this.colorWednesday);
            this.groupBox3.Controls.Add(this.labelControl4);
            this.groupBox3.Controls.Add(this.labelControl3);
            this.groupBox3.Controls.Add(this.labelControl2);
            this.groupBox3.Controls.Add(this.colorSunday);
            this.groupBox3.Controls.Add(this.colorSaturday);
            this.groupBox3.Controls.Add(this.labelControl1);
            this.groupBox3.Controls.Add(this.colorTuesday);
            this.groupBox3.Controls.Add(this.colorMonday);
            this.groupBox3.Location = new Point(0x10, 0x10b);
            this.groupBox3.Name = "groupBox3";
            this.groupBox3.Size = new Size(0x1d8, 0x83);
            this.groupBox3.TabIndex = 4;
            this.groupBox3.TabStop = false;
            this.groupBox3.Text = "M\x00e0u sắc trong bảng chấm c\x00f4ng";
            this.btColorDefault.Location = new Point(0x12, 0x5f);
            this.btColorDefault.Name = "btColorDefault";
            this.btColorDefault.Size = new Size(0x4b, 0x17);
            this.btColorDefault.TabIndex = 0x10;
            this.btColorDefault.Text = "Mặc định";
            this.btColorDefault.Click += new EventHandler(this.btColorDefault_Click);
            this.labelControl8.Location = new Point(0x156, 0x41);
            this.labelControl8.Name = "labelControl8";
            this.labelControl8.Size = new Size(0x24, 13);
            this.labelControl8.TabIndex = 15;
            this.labelControl8.Text = "Ng\x00e0y lễ";
            this.colorHoliday.EditValue = Color.Empty;
            this.colorHoliday.Location = new Point(0x184, 0x3e);
            this.colorHoliday.Name = "colorHoliday";
            this.colorHoliday.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.colorHoliday.Size = new Size(0x31, 20);
            this.colorHoliday.TabIndex = 14;
            this.labelControl7.Location = new Point(0x12, 0x41);
            this.labelControl7.Name = "labelControl7";
            this.labelControl7.Size = new Size(0x1c, 13);
            this.labelControl7.TabIndex = 13;
            this.labelControl7.Text = "Thứ 6";
            this.colorFriday.EditValue = Color.Empty;
            this.colorFriday.Location = new Point(0x37, 0x3e);
            this.colorFriday.Name = "colorFriday";
            this.colorFriday.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.colorFriday.Size = new Size(0x31, 20);
            this.colorFriday.TabIndex = 12;
            this.labelControl5.Location = new Point(0x15f, 0x20);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(0x1c, 13);
            this.labelControl5.TabIndex = 11;
            this.labelControl5.Text = "Thứ 5";
            this.labelControl6.Location = new Point(0xf1, 0x20);
            this.labelControl6.Name = "labelControl6";
            this.labelControl6.Size = new Size(0x1c, 13);
            this.labelControl6.TabIndex = 10;
            this.labelControl6.Text = "Thứ 4";
            this.colorThursday.EditValue = Color.Empty;
            this.colorThursday.Location = new Point(0x185, 0x1d);
            this.colorThursday.Name = "colorThursday";
            this.colorThursday.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.colorThursday.Size = new Size(0x30, 20);
            this.colorThursday.TabIndex = 9;
            this.colorWednesday.EditValue = Color.Empty;
            this.colorWednesday.Location = new Point(0x114, 0x1d);
            this.colorWednesday.Name = "colorWednesday";
            this.colorWednesday.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.colorWednesday.Size = new Size(0x30, 20);
            this.colorWednesday.TabIndex = 8;
            this.labelControl4.Location = new Point(0xe0, 0x41);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x2c, 13);
            this.labelControl4.TabIndex = 7;
            this.labelControl4.Text = "Chủ nhật";
            this.labelControl3.Location = new Point(0x80, 0x41);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x1c, 13);
            this.labelControl3.TabIndex = 6;
            this.labelControl3.Text = "Thứ 7";
            this.labelControl2.Location = new Point(0x7f, 0x23);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x1c, 13);
            this.labelControl2.TabIndex = 5;
            this.labelControl2.Text = "Thứ 3";
            this.colorSunday.EditValue = Color.Empty;
            this.colorSunday.Location = new Point(0x114, 0x3e);
            this.colorSunday.Name = "colorSunday";
            this.colorSunday.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.colorSunday.Size = new Size(0x31, 20);
            this.colorSunday.TabIndex = 4;
            this.colorSaturday.EditValue = Color.Empty;
            this.colorSaturday.Location = new Point(0xa5, 0x3e);
            this.colorSaturday.Name = "colorSaturday";
            this.colorSaturday.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.colorSaturday.Size = new Size(0x31, 20);
            this.colorSaturday.TabIndex = 3;
            this.labelControl1.Location = new Point(0x12, 0x23);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x1c, 13);
            this.labelControl1.TabIndex = 2;
            this.labelControl1.Text = "Thứ 2";
            this.colorTuesday.EditValue = Color.Empty;
            this.colorTuesday.Location = new Point(0xa5, 0x20);
            this.colorTuesday.Name = "colorTuesday";
            this.colorTuesday.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.colorTuesday.Size = new Size(0x30, 20);
            this.colorTuesday.TabIndex = 1;
            this.colorMonday.EditValue = Color.Empty;
            this.colorMonday.Location = new Point(0x38, 0x20);
            this.colorMonday.Name = "colorMonday";
            this.colorMonday.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.colorMonday.Size = new Size(0x30, 20);
            this.colorMonday.TabIndex = 0;
            this.colorMonday.EditValueChanged += new EventHandler(this.colorEdit1_EditValueChanged);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
//            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.xtraScrollableControl1);
            base.Name = "xucTimeKeeperOption";
            base.Size = new Size(0x204, 0x199);
            this.groupBox1.ResumeLayout(false);
            this.cheShowPetitionDialog.Properties.EndInit();
            this.cheShowAssignmentDialog.Properties.EndInit();
            this.groupBox2.ResumeLayout(false);
            this.cheAutoPetition.Properties.EndInit();
            this.cheAutoAssignment.Properties.EndInit();
            this.xtraScrollableControl1.ResumeLayout(false);
            this.xtraScrollableControl1.PerformLayout();
            this.cboTimeKeeperTableDefault.Properties.EndInit();
            this.groupBox3.ResumeLayout(false);
            this.groupBox3.PerformLayout();
            this.colorHoliday.Properties.EndInit();
            this.colorFriday.Properties.EndInit();
            this.colorThursday.Properties.EndInit();
            this.colorWednesday.Properties.EndInit();
            this.colorSunday.Properties.EndInit();
            this.colorSaturday.Properties.EndInit();
            this.colorTuesday.Properties.EndInit();
            this.colorMonday.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void LoadControlTimekeeperFormula()
        {
            this.xucTimekeeperFormula = new HRM.CORE.xucTimekeeperFormula();
            this.xucTimekeeperFormula.Location = new Point(this.groupBox3.Location.X, (this.groupBox3.Location.Y + this.groupBox3.Height) + 12);
            this.xucTimekeeperFormula.Width = this.groupBox3.Width;
            this.xtraScrollableControl1.Controls.Add(this.xucTimekeeperFormula);
        }

        private void LoadOption()
        {
            clsTimeKeeperOption option = new clsTimeKeeperOption();
            this.cboTimeKeeperTableDefault.SelectedIndex = option.TimeKeeperTableDefault;
            this.cheShowAssignmentDialog.Checked = option.ShowAssignmentDialog;
            this.cheShowPetitionDialog.Checked = option.ShowPetitionDialog;
            this.cheAutoAssignment.Checked = option.AutoAssignment;
            this.cheAutoPetition.Checked = option.AutoPetition;
            this.colorMonday.Color = option.MondayColor;
            this.colorTuesday.Color = option.TuesdayColor;
            this.colorWednesday.Color = option.WednesdayColor;
            this.colorThursday.Color = option.ThursdayColor;
            this.colorFriday.Color = option.FridayColor;
            this.colorSaturday.Color = option.SaturdayColor;
            this.colorSunday.Color = option.SundayColor;
            this.colorHoliday.Color = option.HolidayColor;
        }

        public void Save()
        {
            clsTimeKeeperOption.SaveOption(this.cboTimeKeeperTableDefault.SelectedIndex, this.cheShowAssignmentDialog.Checked, this.cheShowPetitionDialog.Checked, this.cheAutoAssignment.Checked, this.cheAutoPetition.Checked, this.colorMonday.Color, this.colorTuesday.Color, this.colorWednesday.Color, this.colorThursday.Color, this.colorFriday.Color, this.colorSaturday.Color, this.colorSunday.Color, this.colorHoliday.Color);
            if (this.xucTimekeeperFormula != null)
            {
                this.xucTimekeeperFormula.Save();
            }
        }
    }
}

